<template>
	<view class="turList">
		<scroll-view scroll-x class="scroll-view" scroll-with-animation>
			<div class="item" v-for="(item, index) in list" :key="index" @click="navtab(item.id)">
				<div class="image">
					<image class="img" :src="`/static${item.img}`" mode="widthFix"></image>
				</div>
				<div class="text">{{item.title}}</div>
			</div>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		props: {
			list: {
				type: Array,
				require: true,
			}
		},
		data() {
			return {
				scrollLeft: 0,
			}
		},
		methods: {
			navtab(id) {
				if (id == 2) {
					uni.navigateTo({
						url: '/pages/search/index?type=karton',
					})
				}
				if (id == 1) {
					uni.navigateTo({
						url: '/pages/search/index',
					})
				} else if (id == 4) {
					uni.navigateTo({
						url: '/pages/toplam/index',
					})
				} else if (id == 3) {
					uni.navigateTo({
						url: '/pages/douyin/index',
					})
				}
			},
		},
	}
</script>

<style lang="scss" scoped>
	.turList {
		padding: 10px 0;
		background-color: #fff;

		.scroll-view {
			white-space: nowrap;
			direction: rtl;
			overflow: hidden;
		}

		.item {
			display: inline-flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			width: 25%;
			// flex-shrink: 0;

			.image {
				width: 64px;
				height: 64px;

				.img {
					width: 100%;
					height: 100%;
				}
			}

			.text {
				height: 24px;
				line-height: 24px;
				text-align: center;
				white-space: nowrap;
			}
		}

	}
</style>